//
//  LGHospitalPlanPatientView.m
//  HeartDiseaseManage
//
//  Created by 1234 on 2023/6/28.
//

#import "LGHospitalPlanPatientView.h"

@interface LGHospitalPlanPatientView()

/**   */
@property (nonatomic , strong)UIButton *titleButton;
/**   */
@property (nonatomic , strong)UIView *lineView;
/**   */
@property (nonatomic , strong)UILabel *nameLabel;
/**   */
@property (nonatomic , strong)UILabel *ageLabel;

@end

@implementation LGHospitalPlanPatientView

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self addSubview:self.titleButton];
        [self addSubview:self.lineView];
        [self addSubview:self.nameLabel];
        [self addSubview:self.ageLabel];
        [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self).offset(viewPix(12));
            make.top.equalTo(self.lineView.mas_bottom).offset(viewPix(13));
        }];
        [self.ageLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.nameLabel.mas_right).offset(viewPix(4));
            make.centerY.equalTo(self.nameLabel);
        }];
    }
    return self;
}

-(void)setDataDic:(NSDictionary *)dataDic{
    _dataDic = dataDic;
    if(dataDic.allKeys.count>0){
        self.nameLabel.text = LGNSString(dataDic[@"realname"]);
        self.ageLabel.text = [NSString stringWithFormat:@"%@ %@岁",dataDic[@"gender"],dataDic[@"age"]];
    }else{
        self.nameLabel.text = @"";
        self.ageLabel.text = @"暂无患者";
    }
}

-(UIButton *)titleButton{
    if(!_titleButton){
        _titleButton = [UIButton buttonWithTitle:@"患者信息" titleFont:LGFontWeight(16, UIFontWeightMedium) textColor:@"#333333" imageName:@"计划入院-患者信息"];
        _titleButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
        _titleButton.frame = CGRectMake(viewPix(12), 0, viewPix(110), viewPix(48));
        _titleButton.titleEdgeInsets = UIEdgeInsetsMake(0, 6, 0, 0);
        _titleButton.userInteractionEnabled = NO;
    }
    return _titleButton;
}

-(UIView *)lineView{
    if(!_lineView){
        _lineView = [[UIView alloc] initWithFrame:CGRectMake(viewPix(12), viewPix(48), Screen_W-viewPix(56), 0.5)];
        _lineView.backgroundColor = [UIColor colorWithString:@"#E8E8E8"];
    }
    return _lineView;
}

-(UILabel *)nameLabel{
    if(!_nameLabel){
        _nameLabel = [UILabel lableWithText:@"" colorString:@"#333333" textFont:LGFont(16) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _nameLabel;
}

-(UILabel *)ageLabel{
    if(!_ageLabel){
        _ageLabel = [UILabel lableWithText:@"" colorString:@"#999999" textFont:LGFont(14) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _ageLabel;
}

@end
